if [ -z "$GITHUB_USERNAME" ]; then 
    read -p "Github username: " GITHUB_USERNAME
fi

# define constant here
INDEX=index.html
TITLE=目录
DIR=${GITHUB_USERNAME}.github.io

if [ ! -d ${DIR} ]
then
    git clone https://github.com/${GITHUB_USERNAME}/${DIR}
    exit
fi

cd  ${DIR}
echo "<meta charset='UTF-8'>" > $INDEX
echo "<style>body{font-size: 2em;}h1,a{text-align: center;display: block;text-decoration: none}</style>" >> $INDEX
echo "<h1>${TITLE}</h1>" >> $INDEX
for i in *.html
do
    if [ $i = $INDEX ]
    then
        continue
    fi
    echo "<a href='https://${DIR}/${i}'>${i%.*}</a>" >> $INDEX
done

git add --all
git commit -m "$(echo docs: $(git status -s))"
git push -u origin master